package com.atguigu.algorithm;

import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Scanner;

public class TelephoneNumber {
    public static HashMap<Character,Integer> map=new HashMap<>();
    public static void initializeMap(){
        map.put('A',2);
        map.put('B',2);
        map.put('C',2);
        map.put('D',3);
        map.put('E',3);
        map.put('F',3);
        map.put('G',4);
        map.put('H',4);
        map.put('I',4);
        map.put('J',5);
        map.put('K',5);
        map.put('L',5);
        map.put('M',6);
        map.put('N',6);
        map.put('O',6);
        map.put('P',7);
        map.put('Q',7);
        map.put('R',7);
        map.put('S',7);
        map.put('T',8);
        map.put('U',8);
        map.put('V',8);
        map.put('W',9);
        map.put('X',9);
        map.put('Y',9);
        map.put('Z',9);
    }
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        while(scanner.hasNext()){
            int n=scanner.nextInt();
            String[] strings=new String[n];
            for(int i=0;i<n;i++){
                strings[i]=scanner.next();
            }
            initializeMap();
            PriorityQueue<String> priorityQueue=new PriorityQueue<>();
            for(int i=0;i<n;i++){
                StringBuilder sb=new StringBuilder();
                String tmp=strings[i];
                for(int j=0;j<tmp.length();j++){
                    char ch=tmp.charAt(j);
                    if(ch>='0' && ch<='9'){
                        sb.append(ch);
                        if(sb.length()==3){
                            sb.append('-');
                        }
                    }else if(ch=='-'){
                        continue;
                    }else{
                        sb.append(map.get(ch));
                        if(sb.length()==3){
                            sb.append('-');
                        }
                    }
                }
                if(!priorityQueue.contains(sb.toString())) {
                    priorityQueue.offer(sb.toString());
                }
            }
            while(!priorityQueue.isEmpty()){
                System.out.println(priorityQueue.poll());
            }
            System.out.println();
        }
    }
}

